<?php
namespace app\admin\controller;

use think\facade\Db;
use think\facade\View;
use think\facade\Config as Configs;
use app\admin\model\Config as ConfigModel;
use think\facade\Request;
class Config extends Base
{
    protected $model = null;
    protected $noNeedRight = ['check'];

    public function _initialize()
    {
        parent::_initialize();

    }
    public function group(){
        $id   = input('id',0);
        $config_group_list=Configs::get('app.configgroup');

        $list = Db::name("Config")->where(['group'=>$id])->select();
        if($list) {
            View::assign([
                'list'=>$list
            ]);
        }
        View::assign([
            'id'=>$id,
            'config_group_list'=>$config_group_list
        ]);
        return view('group');
    }
    public function index(){
        if(Request::instance()->isAjax()){
            $param = input('param.');
            $limit = $param['pageSize'];
            $offset = ($param['pageNumber'] - 1) * $limit;
            $where=[];
            $config=new ConfigModel();
            $selectResult=$config->getConfigsByWhere($where,$offset,$limit);
            $return=[];
            $return['total']=$config->getAllConfigs($where);
            $return['rows']=$selectResult;
            return json($return);
        }
        return view('index');
    }

    public function edit(){}
}